/*
require.config({
    baseUrl: "../../components",
    paths: {
        "echarts": "echarts-4.0.4.min"
    },
    shim: {
        'echarts': {
            deps: [],
            exports: 'echarts'
        }
    }
});
*/
require(["../../components/echarts-4.0.4.min"], function (echarts){

    console.log(111)
    var pieChart = echarts.init(document.getElementById('main'));
    var	data=[
        {value:132, name:'东部地区'},
        {value:170, name:'西部地区'},
        {value:35, name:'南部地区'},
        {value:33, name:'北部地区'},
        {value:12, name:'东北地区'},
        {value:88, name:'中部地区'}
    ]
    var pieOption = {
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b}: {c} ({d}%)"
        },
        color: ['#7a8be4', '#42a4eb' ,"#a34018",'#f36f8a','#fd9173','#4ac7f5'],
        legend: { //图例组件，颜色和名字
            left: '0',
            top: '0',
            orient: 'vertical',
            itemGap: 12, //图例每项之间的间隔
            itemWidth: 10,
            itemHeight: 10,
            icon: 'rect',
            data: ['东部地区', '西部地区', '南部地区', '北部地区', '东北地区','中部地区'],
            textStyle: {
                color: [],
                fontStyle: 'normal',
                fontFamily: '微软雅黑',
                fontSize: 12
            }
        },
        series: [{
            name: '违规次数',
            type: 'pie',
            clockwise: false, //饼图的扇区是否是顺时针排布
            minAngle: 20, //最小的扇区角度（0 ~ 360）
            center: ['50%', '50%'], //饼图的中心（圆心）坐标
            radius: ['50%', '70%'],//饼图的半径
            avoidLabelOverlap: true, ////是否启用防止标签重叠
            itemStyle: { //图形样式
                normal: {
                    borderColor: '#fff',
                    borderWidth: 1
                }
            },
            label: { //标签的位置
                normal: {
                    show: true,
                    position: 'inside', //标签的位置
                    formatter: "{c}",
                    textStyle: {
                        color: '#fff'
                    }
                },
                emphasis: {
                    show: true,
                    textStyle: {
                        fontWeight: 'bold'
                    }
                }
            },
            data: data
        }, {
            name: '',
            type: 'pie',
            clockwise: false,
            silent: true,
            minAngle: 20, //最小的扇区角度（0 ~ 360）
            center: ['50%', '50%'], //饼图的中心（圆心）坐标
            radius: ['0', '50%'],//饼图的半径
            itemStyle: { //图形样式
                normal: {
                    borderColor: '#fff',
                    borderWidth: 0,
                    opacity: 0
                }
            },
            label: { //标签的位置
                normal: {
                    show: false,
                }
            },
            data: data
        }]
    };

    var currentIndex = -1;
    var timer1 = setInterval(function () {
        var dataLen = pieOption.series[0].data.length;
        // 取消之前高亮的图形
        pieChart.dispatchAction({
            type: 'downplay',
            seriesIndex: 0,
            dataIndex: currentIndex
        });
        currentIndex = (currentIndex + 1) % dataLen;
        // 高亮当前图形
        pieChart.dispatchAction({
            type: 'highlight',
            seriesIndex: 0,
            dataIndex: currentIndex
        });
    }, 1000);
    pieChart.setOption(pieOption);
});
